// Scintilla source code edit control
/** @file LexerModule.cxx
 ** Colourise for particular languages.
 **/
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.

#include <cassert>
#include <cstring>

#include <string>
#include <string_view>
#include <vector>
//#include <map>

#include "ILexer.h"
#include "Scintilla.h"
//#include "SciLexer.h"

#include "PropSetSimple.h"
#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "LexerModule.h"
#include "LexerBase.h"

using namespace Lexilla;

//++Autogenerated -- run scripts/LexGen.py to regenerate
//**\(extern LexerModule \*;\n\)
extern LexerModule lmAPDL;
extern LexerModule lmAsm;
extern LexerModule lmAsymptote;
extern LexerModule lmAutoHotkey;
extern LexerModule lmAutoIt3;
extern LexerModule lmAviSynth;
extern LexerModule lmAwk;
extern LexerModule lmBash;
extern LexerModule lmBatch;
extern LexerModule lmCangjie;
extern LexerModule lmCIL;
extern LexerModule lmCMake;
extern LexerModule lmCoffeeScript;
extern LexerModule lmConfig;
extern LexerModule lmCPP;
extern LexerModule lmCSharp;
extern LexerModule lmCSS;
extern LexerModule lmCSV;
extern LexerModule lmDart;
extern LexerModule lmDiff;
extern LexerModule lmDLang;
extern LexerModule lmFortran;
extern LexerModule lmFSharp;
extern LexerModule lmGN;
extern LexerModule lmGo;
extern LexerModule lmGraphViz;
extern LexerModule lmGroovy;
extern LexerModule lmHaskell;
extern LexerModule lmHaxe;
extern LexerModule lmHTML;
extern LexerModule lmInnoSetup;
extern LexerModule lmJamfile;
extern LexerModule lmJava;
extern LexerModule lmJavaScript;
extern LexerModule lmJSON;
extern LexerModule lmJulia;
extern LexerModule lmKotlin;
extern LexerModule lmLatex;
extern LexerModule lmLisp;
extern LexerModule lmLLVM;
extern LexerModule lmLua;
extern LexerModule lmMakefile;
extern LexerModule lmMarkdown;
extern LexerModule lmMathematica;
extern LexerModule lmMatlab;
extern LexerModule lmNim;
extern LexerModule lmNsis;
extern LexerModule lmNull;
extern LexerModule lmOCaml;
extern LexerModule lmPascal;
extern LexerModule lmPerl;
extern LexerModule lmPHPScript;
extern LexerModule lmPowerShell;
extern LexerModule lmProps;
extern LexerModule lmPython;
extern LexerModule lmRebol;
extern LexerModule lmRLang;
extern LexerModule lmRuby;
extern LexerModule lmRust;
extern LexerModule lmSAS;
extern LexerModule lmScala;
extern LexerModule lmSmali;
extern LexerModule lmSQL;
extern LexerModule lmSwift;
extern LexerModule lmTCL;
extern LexerModule lmTexinfo;
extern LexerModule lmTOML;
extern LexerModule lmVBScript;
extern LexerModule lmVerilog;
extern LexerModule lmVHDL;
extern LexerModule lmVim;
extern LexerModule lmVisualBasic;
extern LexerModule lmWASM;
extern LexerModule lmWinHex;
extern LexerModule lmXML;
extern LexerModule lmYAML;
extern LexerModule lmZig;

//--Autogenerated -- end of automatically generated section

namespace {

const LexerModule * const lexerCatalogue[] = {
//++Autogenerated -- run scripts/LexGen.py to regenerate
//**\(\t&\*,\n\)
	&lmAPDL,
	&lmAsm,
	&lmAsymptote,
	&lmAutoHotkey,
	&lmAutoIt3,
	&lmAviSynth,
	&lmAwk,
	&lmBash,
	&lmBatch,
	&lmCangjie,
	&lmCIL,
	&lmCMake,
	&lmCoffeeScript,
	&lmConfig,
	&lmCPP,
	&lmCSharp,
	&lmCSS,
	&lmCSV,
	&lmDart,
	&lmDiff,
	&lmDLang,
	&lmFortran,
	&lmFSharp,
	&lmGN,
	&lmGo,
	&lmGraphViz,
	&lmGroovy,
	&lmHaskell,
	&lmHaxe,
	&lmHTML,
	&lmInnoSetup,
	&lmJamfile,
	&lmJava,
	&lmJavaScript,
	&lmJSON,
	&lmJulia,
	&lmKotlin,
	&lmLatex,
	&lmLisp,
	&lmLLVM,
	&lmLua,
	&lmMakefile,
	&lmMarkdown,
	&lmMathematica,
	&lmMatlab,
	&lmNim,
	&lmNsis,
	&lmNull,
	&lmOCaml,
	&lmPascal,
	&lmPerl,
	&lmPHPScript,
	&lmPowerShell,
	&lmProps,
	&lmPython,
	&lmRebol,
	&lmRLang,
	&lmRuby,
	&lmRust,
	&lmSAS,
	&lmScala,
	&lmSmali,
	&lmSQL,
	&lmSwift,
	&lmTCL,
	&lmTexinfo,
	&lmTOML,
	&lmVBScript,
	&lmVerilog,
	&lmVHDL,
	&lmVim,
	&lmVisualBasic,
	&lmWASM,
	&lmWinHex,
	&lmXML,
	&lmYAML,
	&lmZig,

//--Autogenerated -- end of automatically generated section
};

}

const LexerModule *LexerModule::Find(int language_) noexcept {
	for (const LexerModule *lm : lexerCatalogue) {
		if (lm->GetLanguage() == language_) {
			return lm;
		}
	}
	return &lmNull;
}

Scintilla::ILexer5 *LexerModule::Create() const {
	if (fnFactory) {
		return fnFactory();
	}
	return new LexerBase(this);
}
